<?php
use yii\widgets\LinkPager;
use yii\helpers\Url;
use common\service\UtilService ;
use common\service\ConstatService ;

$pageName = "评价管理";
$controller = Yii::$app->controller->id;
$action = Yii::$app->controller->action->id;
$this->title = $pageName . "-" . Yii::$app->params['webname'];
$this->params['breadcrumbs'][] = $pageName;
$this->params['display_name'] = $pageName;
//评价状态
$statusArr = ConstatService::EVALU_STATUS_ARR ;

//$isMobile = UtilService::isMobile() ;
//if($isMobile==true){
//    $css = "table-responsive" ;
//}else{
//    $css = "" ;
//}

?>

<div class="row">
    <div class="col-md-12">
        <div class="nav-tabs-custom">
            <div class="tab-content">
                <div class="form-group">
                    <button id="add" class="btn btn-primary btn-xs pull-right btn-hide button-add-contral" title="添加评价" type="button"><i class="fa fa-plus"></i>添加</button>
                </div>
            </div>
            <div class="tab-content">
                <div class="tab-pane active">
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-bordered table-striped table-condensed">
                            <tbody>
                            <tr>
                                <th align="center">序号</th>
                                <th align="center">标题</th>
                                <th align="center">状态</th>
                                <th align="center">时间</th>
                                <th align="center">操作</th>
                            </tr>
                            <?php $page = empty($arr['page']->getPage())?0:$arr['page']->getPage() ;?>
                            <?php $pageSize = empty($arr['page']->pageSize)?$limit:$arr['page']->pageSize ;?>
                            <?php $pageSize = $page * $pageSize ; ?>
                            <?php foreach ($arr['list'] as $key=>$value):?>
                                <tr>
                                    <td><?= $pageSize+$key+1?></td>
                                    <td><?= $value['title']; ?></td>
                                    <td><?= empty($statusArr[$value['status']])?"":$statusArr[$value['status']]; ?></td>
                                    <td><?= $value['upd_time']; ?></td>
                                    <td>
                                        <?php $editUrl = Url::to(["/system/edit-evalu","id"=>$value['id']])?>
                                        <a href="javascript:;" url="<?=$editUrl?>" class="btn btn-primary btn-xs evalu_edit">编辑</a>

                                        <?php $delUrl = Url::to(["/system/del-evalu","id"=>$value['id']])?>
                                        <a href="javascript:ajaxMakedo('<?=$delUrl?>', '确认删除？')" class="btn btn-danger btn-xs">删除</a>
                                    </td>
                                </tr>
                            <?php  endforeach;?>
                            <tr>
                                <td colspan="20" class="">
                                    <?=
                                    LinkPager::widget([
                                        'firstPageLabel' => '首页',
                                        'lastPageLabel' => '末页',
                                        'prevPageLabel' => '上一页',
                                        'nextPageLabel' => '下一页',
                                        'pagination' => $arr['page'],
                                        'maxButtonCount' => 8,
                                    ])
                                    ?>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){
        $("#myModal").on("hidden.bs.modal", function() {
            $(this).removeData("bs.modal");
            $(this).find(".modal-content").children().remove();
        }) ;

        $('#add').click(function () {
            var options = {remote: '<?= Url::toRoute('add-evalu') ?>'};
            $('#myModal').modal(options)
        });

        $('.evalu_edit').click(function () {
            var url = $(this).attr('url');
            var options = {remote: url};
            $('#myModal').modal(options)
        });

    });
</script>
